import java.util.Scanner;

public class caishuzi {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLong()) {
            int a = in.nextInt();
            int[] b = new int[4];
            b[3] = a % 10;
            b[2] = a / 10 % 10;
            b[1] = a / 100 % 10;
            b[0] = a / 1000 % 10;
            while (in.hasNextLong()) {
                int n = 0, m = 0;
                int c = in.nextInt();
                int[] d = new int[4];
                d[3] = c % 10;
                d[2] = c / 10 % 10;
                d[1] = c / 100 % 10;
                d[0] = c / 1000 % 10;
                for (int i = 0; i < 4; i++) {

                    for (int j = 0; j < 4; j++) {
                        if (b[i] == d[j]) {
                            if(b[i]==d[i])n++;
                            else m++;
                        };
                    }
                }
                System.out.println( n +"A" + m+"B");
                if (n == 4) break;
            }
        }
    }

}
